package dao

import "context"

type ArticleDAO interface {
	Upsert(ctx context.Context, article PublishArticle) (int64, error)
	Insert(ctx context.Context, article Article) (int64, error)
	Update(ctx context.Context, article Article) (int64, error)
	Sync(ctx context.Context, article Article) (int64, error)
	FindByAuthorId(ctx context.Context, id int64, offset int, limit int) ([]Article, error)
	GetById(ctx context.Context, authorId int64, articleId int64) (Article, error)
	GetPubById(ctx context.Context, articleId int64) (PublishArticle, error)
	ListPub(ctx context.Context, offset int, limit int) ([]Article, error)
}

// Article 制作库PO对象
type Article struct {
	Id       int64  `gorm:"primaryKey;autoIncrement" bson:"id,omitempty"`
	Title    string `gorm:"type=varchar(1024)" bson:"title,omitempty"`
	Content  string `gorm:"type=blob" bson:"content,omitempty"`
	AuthorId int64  `bson:"author_id,omitempty"`
	Ctime    int64  `bson:"ctime,omitempty"`
	Utime    int64  `bson:"utime,omitempty"`
}

// PublishArticle 线上库PO对象
type PublishArticle struct {
	Id       int64  `gorm:"primaryKey;autoIncrement" bson:"id,omitempty"`
	Title    string `gorm:"type=varchar(1024)" bson:"title,omitempty"`
	Content  string `gorm:"type=blob" bson:"content,omitempty"`
	AuthorId int64  `bson:"author_id,omitempty"`
	Ctime    int64  `bson:"ctime,omitempty"`
	Utime    int64  `bson:"utime,omitempty"`
}
